package com.keste.adf.ui.bean.session;

import com.keste.adf.ui.login.SQLAuthenticatorAdapter;

import org.apache.log4j.Logger;

public class GlobalInfo {
    static final Logger logObject = Logger.getLogger(GlobalInfo.class);
    
    public GlobalInfo() {
        super();
    }
    
    private boolean initilized = false;
    private boolean dbConnected = false;
    private SQLAuthenticatorAdapter DBConnector;

    public void setInitilized(boolean initilized) {
        this.initilized = initilized;
    }

    public boolean isInitilized() {
        return initilized;
    }
    
    public void initializeConnection()
    {
        try{
            if(!isDbConnected())
            {
                DBConnector = new SQLAuthenticatorAdapter();
                DBConnector.connect();
                setDbConnected(true);
            }
        }
        catch(Exception ex)
        {
            setDbConnected(false);
            ex.printStackTrace();
        }
    }
    
    public void closeConnection()
    {
        try{
            DBConnector.close();
            setDbConnected(false);
        }catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

    public void setDbConnected(boolean dbConnected) {
        this.dbConnected = dbConnected;
    }

    public boolean isDbConnected() {
        return dbConnected;
    }
}
